/**
 * 功能说明：前端缓存
 * @author cwj
 * @author 2015-01-06
 */

define(function(require, exports, module) {
	var Storage = require('Storage');
	// 本地存储校验规则
    var setStorageName = function(name) {
        var names = name.toString().split('_');
        if(names.length < 5) {
            throw Error('请按照规则输入名称，规则为M_controller名称+action名称+view名称+数据名');
        }

        return name;
    };

    var cache = {};
    // localStorage
    cache.localcache = new Storage({
        setRealName: setStorageName
    });
    // sessionStorage
    cache.sessioncache = new Storage({
        type: 'session',
        setRealName: setStorageName,
    });

    module.exports = cache;
});